package net.atomarrow.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * 线程池
 * @author Michael
 *
 */
public class ThreadPool {

	private ExecutorService executorService;
	private static ThreadPool threadPoll;
	public static ThreadPool getInstance(){
		if(threadPoll==null){
			threadPoll = new ThreadPool(3);
		}
		return threadPoll;
	}
	public static ThreadPool getInstance(int count){
		if(threadPoll==null){
			threadPoll = new ThreadPool(count);
		}
		return threadPoll;
	}
	private ThreadPool(int count){
		executorService = Executors.newFixedThreadPool(count);  
	}
    public void execute(Runnable runnable){
    	executorService.execute(runnable);
    }
}
